<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h2>Pesquisar Usuário</h2>

            <p:panel styleClass="container_24 clearfix " style="background: none; border: none;"> 
                <h:form id="form" acceptcharset="utf-8">
                    <p:growl id="msg" life="3000" autoUpdate="true"/>

                    <p class="subtitle">Filtros</p>

                    <p:outputLabel value="Nome : " styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarUsuario.usuario.nome}"/>
                    <div class="clear"/>
                    <p:outputLabel value="Login :" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarUsuario.usuario.login}"/>

                    <div class="buttonAction">
                        <p:commandButton id="bt_pesquisar" value="Pesquisar" icon="ui-icon-search"
                                         update="tableUsuario"
                                         actionListener="#{managerPesquisarUsuario.pesquisar()}"
                                         styleClass="ui-priority-primary" />
                        <p:button href="indexusuario.xhtml" value="Cancelar" icon="ui-icon-circle-close"/>
                    </div>

                    <p class="subtitle">Resultado</p>
                    <p:dataTable id="tableUsuario" var="item" value="#{managerPesquisarUsuario.usuarios}" 
                                 styleClass="grid_24" rowIndexVar="rowid" 
                                 style="white-space: pre-wrap;"
                                 rowKey="#{item.id}" rows="5" paginator="true"  
                                 paginatorPosition="bottom" emptyMessage="Nenhum registro">  
                        <f:facet name="header">
                            <p:outputLabel value="Usuário" />
                        </f:facet>
                        <p:column headerText="Ação" width="10px;" > 
                            <p:button title="Editar"
                                      href="editarusuario.xhtml?usuEd=#{item.id}"
                                      icon="ui-icon-pencil"/>
                            <p:button title="Visualizar" 
                                      href="visualizarusuario.xhtml?usuVi=#{item.id}"
                                      icon="ui-icon-zoomin"/> 
                            <p:button title="Alterar"  
                                      href="alterarlogin.xhtml?usuLo=#{item.id}"
                                      icon="ui-icon-unlocked"/> 
                            <p:commandButton title="Excluir" 
                                             oncomplete="dlg.show();" 
                                             update="@form" rendered="#{managerPesquisarUsuario.admin}"
                                             actionListener="#{managerPesquisarUsuario.setUsuariorr(item)}"
                                             icon="ui-icon-trash"/>
                            <!--                                <p:button title="Acesso" 
                                                                      href="acessousuario.xhtml?usuAc={item.id}"
                                                                      icon="ui-icon-zoomin"/> -->


                        </p:column>
                        <p:column headerText="Nome"> 
                            <p:outputLabel value="#{item.nome}"/>
                        </p:column>

                    </p:dataTable>
                    
                </h:form>

                <h:form>
                    <p:panel id="paneldlg">
                        <p:dialog id="iddlg" header="Exclusão" widgetVar="dlg" modal="false"
                                  showEffect="fade" hideEffect="fade" resizable="false" height="20">  
                            <h:outputText value="Deseja Excluir esse Registro ?" /> <br/> 
                            <f:facet name="footer">

                                <center>
                                    <p:commandButton value="Sim" id="idb"
                                                     update="@form, :form:tableUsuario"
                                                     icon="ui-icon-check"
                                                     actionListener="#{managerPesquisarUsuario.excluir()}" />
                                    <p:commandButton value="Não" process="@this" onclick="dlg.hide()" icon="ui-icon-close" />
                                </center>

                            </f:facet>
                        </p:dialog>   
                    </p:panel>

                </h:form>
            </p:panel> 
        </ui:define>
    </ui:composition>
</html>